为什么 VB 对话框设计时“|”错误 (竟被认为是无效字符)

来源:百度知道 编辑:UC知道 时间:2024/06/18 07:23:05
按书上的原样打到电脑上的 添加一个命令按钮和对话框控件后
Private Sub Command1_Click()
CommonDialog1.Filter = (textfile |(*.txt) | wordfile | (*.doc))
CommonDialog1.ShowOpen
End Select

请问高手前辈们,这是为什么啊?
急求!!!
1楼 kunwang2 的做法得到如图:
下面的文件类型显示是没问题,但是本来应是正常的文件过滤把所有文件都过滤了,一个文件也显示不了,只能显示文件夹类型的东西:比如说如图,我在桌面放了一个 txt 和 一个 doc 文件 ,但都没有显示出来。
2楼 AlphaBlend 做法出现了 错误提示
修改后(不知道我的修改算不算修改)还是不行,文件类型显示不正常,只显示txt,文件浏览过滤无作用,什么文件都现在,根本不存在过滤。

Private Sub Command1_Click()
CommonDialog1.Filter = "textfile |(*.txt) | wordfile |(*.doc)|"
CommonDialog1.ShowOpen
End Select

CommonDialog1.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "wordfile(*.doc)" + Chr$(0) + "*.doc" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)

用 Chr$(0) 来分割

CommonDialog1.Filter = "textfile |(*.txt) | wordfile | (*.doc)"